#ifndef FIX_QUEUE_H
#define FIX_QUEUE_H

#include "sys.h"
#include "stdtypes.h"
#include "net_err.h"
#include "nlist.h"
// #include <stdatomic.h>
#if 0
typedef nlist_node_t suspend_thread_list;

typedef struct {
    nlist_node_t *suspend_list;
    sys_thread_t suspend_thread;
} queue_suspend_list;
#endif

typedef struct _fix_queue_t {
    int size;
    int in, out, cnt;
    int recv_wait_cnt;
    int send_wait_cnt;
    #if 0
    nlist_node_t *suspend_w;
    nlist_node_t *suspend_r;
    #endif
    sys_event_t write_enable;
    sys_event_t read_enable;
    
    sys_mutex_t qmutex;
    void **buf;
} fix_queue_t;

net_err_t fix_queue_init(fix_queue_t *q, void **buf, u32 size);
net_err_t fix_queue_send(fix_queue_t *q, void *msg, int time);
void * fix_queue_recv(fix_queue_t *q, int time);
#endif